home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2006 May / PCWMAY06.iso / Software / Freeware / First Page 2006 3.00 / fp2006-final-3.00-setup.exe / {app} / Iscripts / Maths & Calculations / count-down-until-any-date.izs < prev    next >
Text File  |  2005-07-20  |  2KB  |  81 lines

  1. <!NOWIZARD>
  2.  
  3. <!TITLE>Count down until any date
  4. <!/TITLE>
  5.  
  6. <!DESCRIPTION>A versatile and practical script that can be used to count down until any given date. 
  7. <!/DESCRIPTION> 
  8.  
  9. <!CATEGORY>Counters<!/CATEGORY>
  10.  
  11. <!SCRIPT>
  12. <!-- START OF SCRIPT -->
  13. <!-- Simply insert the below into the <body> section of your page:  -->
  14. <script>
  15.  
  16.  
  17.  
  18. //change the text below to reflect your own,
  19. var before="Valentines day!"
  20. var current="Today is Valentines day. Don\'t forget the flowers!"
  21. var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
  22.  
  23. function countdown(yr,m,d){
  24. var today=new Date()
  25. var todayy=today.getYear()
  26. if (todayy < 1000)
  27. todayy+=1900
  28. var todaym=today.getMonth()
  29. var todayd=today.getDate()
  30. var todaystring=montharray[todaym]+" "+todayd+", "+todayy
  31. var futurestring=montharray[m-1]+" "+d+", "+yr
  32. var difference=(Math.round((Date.parse(futurestring)-Date.parse(todaystring))/(24*60*60*1000))*1)
  33. if (difference==0)
  34. document.write(current)
  35. else if (difference>0)
  36. document.write("Only "+difference+" days until "+before)
  37. }
  38. //enter the count down date using the format year/month/day
  39. countdown(2002,2,14)
  40. </script>
  41.  
  42. <!-- END OF SCRIPT -->
  43. <!/SCRIPT>
  44.  
  45. <!PREVIEW>
  46. <!-- START OF SCRIPT -->
  47. <!-- Simply insert the below into the <body> section of your page:  -->
  48. <script>
  49.  
  50.  
  51.  
  52. //change the text below to reflect your own,
  53. var before="Valentines day!"
  54. var current="Today is Valentines day. Don\'t forget the flowers!"
  55. var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
  56.  
  57. function countdown(yr,m,d){
  58. var today=new Date()
  59. var todayy=today.getYear()
  60. if (todayy < 1000)
  61. todayy+=1900
  62. var todaym=today.getMonth()
  63. var todayd=today.getDate()
  64. var todaystring=montharray[todaym]+" "+todayd+", "+todayy
  65. var futurestring=montharray[m-1]+" "+d+", "+yr
  66. var difference=(Math.round((Date.parse(futurestring)-Date.parse(todaystring))/(24*60*60*1000))*1)
  67. if (difference==0)
  68. document.write(current)
  69. else if (difference>0)
  70. document.write("Only "+difference+" days until "+before)
  71. }
  72. //enter the count down date using the format year/month/day
  73. countdown(2002,2,14)
  74. </script>
  75.  
  76.  
  77.  
  78. <!-- END OF SCRIPT -->
  79. <!/PREVIEW>
  80.  
  81. <!RELATED>NONE<!/RELATED>